<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<title>${aier_title}</title>
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link rel="Stylesheet" href="${aier_css_url}jq/jq.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/reset.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/btn.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/icon.css" />
<link rel="Stylesheet" href="${aier_css_url}social/module/emotion.css" />
<link rel="Stylesheet" href="${aier_css_url}social/module/homeside.css" />
<link rel="stylesheet" href="${aier_css_url}social/user/userMessage/usermessage.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/xxs.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}${aier_jqui_js}ui.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}97/WdatePicker.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript"
	src="${aier_js_url}emotion/xxsemotion.2.js"></script>
<script type="text/javascript" src="${aier_js_url}trantime/jquery-aier.js"></script>

</head>
<body>

	<!-- 顶栏 -->
	<s:action name="userhomecomm_homeHead" namespace="/user" executeResult="true"></s:action>
	<!-- 顶栏结束 -->

	<!-- 主区域 -->

	<div class="window-content">

		<!-- wrap  -->
		
		<div class="wrap wrap-msg wrap-message wrap-tri-col clearfix">

			<!-- 主侧栏 -->
			<s:action name="usermessage_msgSide" namespace="/user" executeResult="true"></s:action>
	 
            <div id="deleteConfirm" style="display: none;" title="删除">
                <p>确认要删除此通知吗?</p>
            </div>

			<!-- 主区域 (右  -->
			<div class="msg-main clearfix">
				<div class="msg-stream">

				<div class="message-stream msg-stream-notice">

					
					<div class="notice-title title">
						<div class="group">
							通知
						</div>
					</div>
					<!-- 删除通知 -->
					<div class="title-bottom-function">
						<a class="btn-normal-orange delete-all" id="btnDeleteAllNotice">
							<span>删除全部</span>
						</a> 
						<div id="dialogDeleteAllNotice" title="删除全部通知" style="display:none">
							<p>确认删除全部通知吗?</p>
						</div>
					</div>
					<!-- /删除通知 -->
					<div class="notice-stream clearfix" id = "notice">
						
						<!-- 时间 
						<fieldset class="notice-timeline">
							<legend>8月8日 16:39</legend>
						</fieldset>-->

					</div>
                    <div id = "page"></div>
				</div>
                    
				</div>

                <!-- 右栏 -->
                <s:action name="userhomecomm_homeRight" namespace="/user" executeResult="true"></s:action>

			</div>

			<!-- 回到顶部 -->
			<s:action name="userhomecomm_backToTop" namespace="/user" executeResult="true"></s:action>
			<!-- 回到顶部结束  -->

	</div>
		<!-- footer copyright -->
		<s:action name="userhomecomm_homeFooter" namespace="/user" executeResult="true"></s:action>
		<!-- /footer copyright -->
</div>
<!-- script -->
<script type="text/javascript">
var page = 1;       // 当前页
var page_size = 10; // 每页的记录数

$("#tabs").tabs();
	$('.text').each(function(){
        $(this).tranText({
        	emotionUrl: '${aier_js_url}trantime/emotions.js'
        });
    });
    
    searchNotice(page);
    function searchNotice(nowpage) {
        page = nowpage;
        // 获取通知列表
        var fun=function(data){
            if(data.s==1){
                var html = "";
                if (null != data.noticeList) {
                    for (var i=0;i<data.noticeList.length;i++) {
                        var notice = data.noticeList[i];
                        html += "<fieldset class='notice-timeline'><legend>"+notice.cdate.split("T")[0]+" "+notice.cdate.split("T")[1]+"</legend></fieldset>";
                        html += "<div class='notice-item clearfix'><div class='notice-avatar'><a href='javascript:void(0);'><img src='${aier_img_url}social/userMessage/avatar_50/0.jpg' alt=''></a></div>"+
                        "<div class='notice-content'><div class='notice-arrow'><em>&diams;</em><span>&diams;</span></div><div class='notice-main'><div class='text'>"+
                        notice.content+"</div></div><div class='notice-screen'><a class='notice-screen-btn' onclick='deleteNotice("+notice.nid+");'>x</a>"+
                        //"<div style='display: none;' id='deleteConfirm' title='删除'><p>确认删除吗?</p></div>"+
                        "</div></div></div>";
                        //"<ul class='notice-screen-list'><li><a onclick='deleteNotice("+notice.nid+");'>删除</a></li></ul></div></div></div>";
                    
                    }
                }
                $("#notice").html(html);
                $('.text').each(function(){
			        $(this).tranText({
			        	emotionUrl: '${aier_js_url}trantime/emotions.js'
			        });
			    });
			    // 更新分页显示
			    page = data.page;
                toLoadPage(page, page_size, data.page_count, data.count, "page", "searchNotice", null, null);
                if (data.count == 0) {
                    $("#page").css("display","none");
                } else {
                    $("#page").css("display","block");
                }
            }
            
        };
        exeAjax(
             ajaxUrl("${aier_url}${aier_urijs}usermessage_searchNoticeList${aier_suffix}"),
             fun,{
                "page":page,
                "page_size":page_size
        });
    }
    
    // 删除通知
    function deleteNotice(nid) {
        $(function() {
		    $("#deleteConfirm").dialog(
		        {
		            //背景变暗
		            modal : true,
		            autoOpen : false,
		            show : "fade",
		            hide : "fade",
		            width : "340",
		            height : "220",
		            buttons : {
		                "确定" : function() {
		                    // 获取通知列表
					        var fun=function(data){
					            if(data.s==1){
					                $("#deleteConfirm").dialog("close");
					                searchNotice(page);
					            } else {
					                $("#deleteConfirm").dialog("close");
					                $().message("删除失败，请稍后再试！");
					            }
					            
					        };
					        exeAjax(
					             ajaxUrl("${aier_url}${aier_urijs}usermessage_deleteNotice${aier_suffix}"),
					             fun,{
					                "nid":nid
					        });
							                },
		                "取消" : function() {
		                    $(this).dialog("close");
		                }
	            }
	        });
	        $("#deleteConfirm").dialog("open");
		});
        
    }
    
    $(document).ready(function() {
      
        // 获取关注分组
        var fun=function(data){
            if(data.s==1){
                var c = "";
                for (var i=0;i<data.fgList.length;i++) {
                    if (data.fgList[i].name == "特别关注") {
                        c += "<div class='tab-normal'><a class='btn' href='${aier_url}user/userhomeforums_homeForums.shtml?fgid="+data.fgList[i].fgid+"'><em class='icon-1 icon-1-teguan'></em><span>"+data.fgList[i].name+"</span></a></div>";
                    } else {
                        c += "<div class='tab-normal'><a class='btn' href='${aier_url}user/userhomeforums_homeForums.shtml?fgid="+data.fgList[i].fgid+"'><em class='icon-1 icon-1-weifen'></em><span>"+data.fgList[i].name+"</span></a></div>";
                    }
                    
                }
                $("#group").html(c);
                
            }
        };
        exeAjax(
             ajaxUrl("${aier_url}${aier_urijs}usermyfollow_searchFollowGroup${aier_suffix}"),
             fun,{
        });
    });

// 删除全部通知
$("#btnDeleteAllNotice").click(function(){
	var thisDialog = $("#dialogDeleteAllNotice");
	thisDialog.dialog({
	    //背景变暗
	    modal : true,
	    autoOpen : false,
	    show : "fade",
	    hide : "fade",
	    width : "340",
	    height : "220",
	    buttons : {
        	"确定" : function() {
                // 获取通知列表
                var fun=function(data){
                    if(data.s==1){
                        thisDialog.dialog("close");
                        $("#notice").html("");
                    } else {
                        thisDialog.dialog("close");
                        $().message("删除失败，请稍后再试！");
                    }
                    
                };
                exeAjax(
                     ajaxUrl("${aier_url}${aier_urijs}usermessage_deleteAllNotice${aier_suffix}"),
                     fun,{
                });
            },
	        "取消" : function() {
              	thisDialog.dialog("close");
            }
        }
    });
	thisDialog.dialog("open");

});

// 跳转到家校联系薄
    function hsConBook() {
        // 判断是否付费

        // 判断身份（家长或老师）

        // 教师（tid）
        //window.location.href = "${aier_url}user/userhscb_userTeaHSConBook.shtml?tid=2&&cid=1";
        var fun = function(data) {
            if (data.s == 1) {

                if (data.type == 0) {
                    $().message("您目前没有权利进入家校联系薄！");
                    return;
                } else if (data.type == 1 || data.type == 3) {
                    if (data.classList != null && data.classList.length > 0) {
                        window.location.href = "${aier_url}user/userhscb_userTeaHSConBook.shtml?cid="
                                + data.classList[0].cid +"&type="+data.type;
                    } else {
                        window.location.href = "${aier_url}user/userhscb_userTeaHSConBook.shtml?type="+data.type;
                    }

                } else if (data.type == 2) {
                    window.location.href = "${aier_url}user/userhscb_userChiHSConBook.shtml?type="+data.type;
                }

            }
        };
        exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}userhscb_searchClassList${aier_suffix}"),
                fun, {});

    }
</script>
</body>
</html>